//
//  SingerCollectionViewCell.m
//  LuckyRadio
//
//  Created by Mr、J on 15/11/21.
//  Copyright © 2015年 chenjun. All rights reserved.
//

#import "SingerCollectionViewCell.h"
#import <UIImageView+WebCache.h>
#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width

#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height

#define WIDTH_PRO(X) (X)*(SCREEN_WIDTH/375)

#define HEIGHT_PRO(Y) (Y)*(SCREEN_HEIGHT/667)

@implementation SingerCollectionViewCell
- (void)dealloc
{
    [_singerModel release];
    [_image release];
    [_titleLabel release];
    [super dealloc];
}

-(instancetype)initWithFrame:(CGRect)frame
{
    if ([super initWithFrame:frame]) {
        [self createSubViews];
    }
    return self;
}

-(void)createSubViews
{
    self.image = [[UIImageView alloc] init];
    [self.contentView addSubview:self.image];
    self.image.layer.cornerRadius = WIDTH_PRO(5);
    self.image.clipsToBounds = YES;
    [_image release];
    
    
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:self.titleLabel];
    [_titleLabel release];
}


-(void)layoutSubviews
{
    [super layoutSubviews];
    
    self.image.frame = CGRectMake(0, HEIGHT_PRO(10), (SCREEN_WIDTH - WIDTH_PRO(40)) / 3, (SCREEN_WIDTH - WIDTH_PRO(40)) / 3);
    self.titleLabel.frame = CGRectMake(self.image.frame.origin.x, self.image.frame.origin.y + self.image.frame.size.height + HEIGHT_PRO(10), self.image.frame.size.width, HEIGHT_PRO(20));
}

-(void)setSingerModel:(SingerModel *)singerModel
{
    if (_singerModel != singerModel) {
        [_singerModel release];
        _singerModel = [singerModel retain];
    }
    
    [self.image sd_setImageWithURL:[NSURL URLWithString:singerModel.pic_url] placeholderImage:[UIImage imageNamed:@"Read_zhanwei"]];
    self.titleLabel.text = singerModel.title;
    
}


@end
